
public class List {
	private node first;
	private node last;
	private int size;
	
	public List()
	{
		this.first=null;
		this.last=null;
		this.size=0;
	}
	/**
	 * 
	 * @return the size of the queue
	 */
	public List(List firstList,List secondList) {
		this.first=firstList.first;
		this.last=firstList.last;
		this.last.next=secondList.first;
		this.last=secondList.last;
		this.size=firstList.size+secondList.size;
	}
	
	public int getSize()
	{
		return size;
	}
	/**
	 * 
	 * @return true if the queue is empty, false if it still has nodes
	 */
	public boolean isEmpty()
	{
		return first==null;
	}
	/**
	 * Adds a passanger to the back of the line
	 * @param id - the ID of the passanger to be added
	 */
	public void enqueue (int id)
	{
		size++;
		node temp = new node(last,id);
		last = temp;
		if(first==null)
			first=temp;
	}
	/**
	 * Remove the first passenger in the line
	 * @return The data from the removed node
	 */
	public int dequeue()
	{
		size--;
		int id=first.data;
		first=first.next;
		return id;
	}
	
	
	private class node
	{
		node next;
		int data;
		
		public node(node last,int id)
		{
			data=id;
			if(last!=null)
				last.next=this;
		}
	}

}
